var express = require('express');
var router = express.Router();
const QuestModel = require("../db/questModel");
const AnswerModel = require("../db/answerModel");

module.exports = (req, res) => {
    const id = req.params["id"]
    QuestModel.remove({"id":parseInt(id)},function(error,ret){
        if(!error) {
            AnswerModel.remove({"questid": parseInt(id),"username":req.user.username},function(error,ret){
                if(!error){
                    res.send({
                        "code": 1,
                        "msg": "删除成功"
                    })
                }
                else{
                    res.send({
                        "code":0,
                        "msg":error
                    })
                }
            })

        }
        else{
            res.send({
                "code":0,
                "msg":error
            })
        }
    })
};

